//
//  DBHelper.m
//  ImGuider
//
//  Created by llt on 2017/4/14.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "DBHelper.h"
#import "FileManager.h"

@implementation DBHelper

+ (NSString *)getQueueDBPath {
    NSString * str = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    NSString * dbPath =  [str stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.sqlite",DB_NAME]];
    
    IGLog(@"----------db Path ----- %@",dbPath);
    return dbPath;
}

+ (FMDatabaseQueue *)getDatabaseQueue {
    
    static FMDatabaseQueue *dbQueue;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSString * dbPath = [self getQueueDBPath];
        dbQueue = [FMDatabaseQueue databaseQueueWithPath:dbPath];
    });
    
    return dbQueue;
}



//+ (void)addCloumnWithDB:(FMDatabase *)db cloumnName:(NSString *)cloumn tableName:(NSString *)table {
//    
//    BOOL bExist = [db columnExists:cloumn inTableWithName:table];
//    
//    if (!bExist) {
//        NSString *sql = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ double ",table,cloumn];
//        [db executeUpdate:sql];
//        NSString *sql2 = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ double ",table,cloumn];
//        [db executeUpdate:sql2];
//    }
//}

@end
